import config
import webapi
import util

def get_issue_data(issue_url,start_time):
    api_data = webapi.get_issue_data(issue_url, start_time)
    data_df = util.clean_issue_data(api_data)
    return data_df


def main(config):
    for _ in config['repository_list']:
        issue_url = config['base_url']+'/repos{}/issues'.format(_)
        data = get_issue_data(issue_url ,config['plan']['start_time'])
        data.to_csv(config['data_path']['issue'].format(_.split('/')[-1])+'.csv')
        # data.to_excel(config['data_path']['issue'].format(_.split('/')[-1])+'.xlsx')

if __name__ == '__main__':
    _config = config.get_config()
    main(_config)